package com.sjb.stock.config;

import com.sjb.stock.utils.IdWorker;
import com.sjb.stock.vo.StockInfoConfig;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * @FileName CommonConfig
 * @Description 定义公共的配置类
 * @Author chm
 * @date 2025/6/28
 **/
@Configuration
@EnableConfigurationProperties(StockInfoConfig.class)
public class CommonConfig {
    /**
     * @return org.springframework.security.crypto.password.PasswordEncoder
     * @description: 定义密码加密匹配器
     * @author chm
     * @date 2025/6/28
     **/
    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }

    /**
     * @description: 基于雪花算法生成的唯一性id
     * @param
     * @return com.sjb.stock.utils.IdWorker
     * @author chm
     * @date 2025/7/2
     **/
    @Bean
    public IdWorker idWorker() {
        return new IdWorker(1L, 1L);
    }

}
